package cn.itcast.service.impl;

import cn.itcast.dao.BranchCourtsDao;
import cn.itcast.pojo.Address;
import cn.itcast.service.BranchCourtsService;
import com.alibaba.dubbo.config.annotation.Service;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class BranchCourtsServiceImpl implements BranchCourtsService {

    @Autowired
    private BranchCourtsDao branchCourtsDao;

    @Override
    public List<Address> pageQuery() {
        List<Address> addresses = branchCourtsDao.pageQuery();
        return addresses;
    }

    @Override
    public boolean addBranchCourts(Address address) {
        if (StringUtils.isNotBlank(address.getCode()) && StringUtils.isNotBlank(address.getName())) {
            branchCourtsDao.addBranchCourts(address);
            return true;
        }
        return false;
    }

    @Override
    public Address findById(Integer id) {
        return branchCourtsDao.findById(id);
    }

    @Override
    public boolean updateBranchCourts(Address address) {
        if (StringUtils.isNotBlank(address.getCode()) && StringUtils.isNotBlank(address.getName())) {
            branchCourtsDao.updateBranchCourts(address);
            return true;
        }
        return false;
    }

    @Override
    public void deleteById(Integer id) {
        branchCourtsDao.deleteById(id);
    }

    @Override
    public void updateEnableById(Integer id, Integer enable) {
        branchCourtsDao.updateEnableById(id, enable);
    }


}
